﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcAppDemo.Models.Dinner>" %>
<%--<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2" type="text/javascript"></script>
<script src="../../Scripts/VirtualEarthMap.js" type="text/javascript"></script>--%>
<div id="theMap">
</div>
<div style="color: #999; position: relative; right: 0px; top: 0px;" id="divPos">
    经度：<label style="width: 120px;"><%=Model.Latitude.ToString("#,00.000000")%></label>&nbsp;纬度：<label style="width: 120px;"><%=Model.Longitude.ToString("#,00.000000")%></label></div>
<script type="text/javascript"> 
$(document).ready(function() {
    var latitude = <%=Model.Latitude%>;
    var longitude = <%=Model.Longitude%>; 
    if ((latitude == 0) || (longitude == 0))
        LoadMap();
    else
        LoadMap(latitude, longitude, mapLoaded);
    }); 
function mapLoaded() {
    var title = "<%=Html.Encode(Model.Title) %>";
    var address = "<%=Html.Encode(Model.Address) %>"; 
    LoadPin(center, title, address);
    map.SetZoomLevel(13);
    map.AttachEvent("onclick",showClickPos);
}
 function showClickPos(e) {
    var x = e.mapX;
    var y = e.mapY;
    pixel = new VEPixel(x, y);
    LL = map.PixelToLatLong(pixel);
    var lat = LL.Latitude;
    var lot = LL.Longitude;
    lat = Math.round(lat*1000000)/1000000;
    lot = Math.round(lot*1000000)/1000000;
    $("#divPos label").each(function(i){
        if(i==0) $(this).text(lat);
        else $(this).text(lot);
    });
}
</script>
